package enums;

import java.util.Arrays;

public enum PayChannelEnum {
    ALI_PAY(1, "ali_pay", "支付宝"),
    WX_PAY(2, "wx_pay", "微信"),
    UN_KNOW(9999999, "UN_KNOW", "未配置的支付渠道");

    private Integer id;
    private String code;
    private String desc;

    private PayChannelEnum(Integer id, String code, String desc) {
        this.id = id;
        this.code = code;
        this.desc = desc;
    }

    public Integer getId() {
        return this.id;
    }

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.desc;
    }

    public static PayChannelEnum getPayChannelEnum(Integer id) {
        return null == id ? UN_KNOW : (PayChannelEnum) Arrays.stream(values()).filter((p) -> {
            return p.getId().equals(id);
        }).findAny().orElse(UN_KNOW);
    }
}
